package com.atguigu.userprofile.mapper;

import com.atguigu.userprofile.bean.UserGroup;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zhangchen
 * @since 2021-05-04
 */
@DS("mysql")
public interface UserGroupMapper extends BaseMapper<UserGroup> {

    @DS("clickhouse")    //区分数据源
    @Insert("${sql}")    //执行整条sql
    public void  insertSqlClickhouse( @Param("sql") String insertSQL);

    @DS("clickhouse")    //区分数据源
    @Select("${sql}")    //执行整条sql
    public Long  countSqlClickhouse( @Param("sql") String selectSQL);

    @DS("clickhouse")    //区分数据源
    @Delete("alter table user_group delete where user_group_id=#{id}") //1语法 alter 2 注意底层操作 不是单条数据操作 整分区操作
    public void deleteUserGroupById(@Param("id") String userGroupId);

    @DS("clickhouse")    //区分数据源
    @Select("select  arrayJoin( bitmapToArray(us) ) from user_group  where user_group_id =#{id}")
    public List<String> selectUidList(@Param("id") String userGroupId);


}
